import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PayAccountVO, PayAccountForm, PayAccountQuery } from '@/api/system/PayAccount/types';

/**
 * 查询收款账号列表
 * @param query
 * @returns {*}
 */

export const listPayAccount = (query?: PayAccountQuery): AxiosPromise<PayAccountVO[]> => {
  return request({
    url: '/system/PayAccount/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询收款账号列表
 * @param query
 * @returns {*}
 */
export const queryListPayAccount = (query?: PayAccountQuery): AxiosPromise<PayAccountVO[]> => {
  return request({
    url: '/system/PayAccount/queryList',
    method: 'get',
    params: query
  });
};

/**
 * 查询收款账号详细
 * @param accountId
 */
export const getPayAccount = (accountId: string | number): AxiosPromise<PayAccountVO> => {
  return request({
    url: '/system/PayAccount/' + accountId,
    method: 'get'
  });
};

/**
 * 新增收款账号
 * @param data
 */
export const addPayAccount = (data: PayAccountForm) => {
  return request({
    url: '/system/PayAccount',
    method: 'post',
    data: data
  });
};

/**
 * 修改收款账号
 * @param data
 */
export const updatePayAccount = (data: PayAccountForm) => {
  return request({
    url: '/system/PayAccount',
    method: 'put',
    data: data
  });
};

/**
 * 删除收款账号
 * @param accountId
 */
export const delPayAccount = (accountId: string | number | Array<string | number>) => {
  return request({
    url: '/system/PayAccount/' + accountId,
    method: 'delete'
  });
};

/**
 * 查询收款账号订单统计
 *
 */
export const getPayChart = (data: Array<string | number>) => {
  return request({
    url: '/system/PayChart/account',
    method: 'post',
    data: {
      accountIds: data
    }
  });
};


/**
 * 还原回收站账号
 */
export const restoreAccounts = (id) => {
  return request({
    url: '/system/PayAccount/restore/' + id,
    method: 'get',
  });
};

/**
 * 还原所有回收站账号
 */
export const restoreAccountsAll = () => {
  return request({
    url: '/system/PayAccount/restoreAll',
    method: 'get',
  });
};


/**
 * 删除回收站账号
 */
export const deleteAccounts = (id) => {
  return request({
    url: '/system/PayAccount/delete/' + id,
    method: 'get',
  });
};

/**
 * 删除所有回收站账号
 */
export const deleteAccountsAll = (id) => {
  return request({
    url: '/system/PayAccount/deleteAll',
    method: 'get',
  });
};